

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>The networking module &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="index.html">pyamp v1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyamp.networking">
<span id="the-networking-module"></span><h1>The networking module<a class="headerlink" href="#module-pyamp.networking" title="Permalink to this headline">¶</a></h1>
<p>The networking module contains various modules pertaining to
setting up system components in a networked fashion (e.g., through
server and client sockets).</p>
<div class="section" id="the-connection-class">
<h2>The Connection class<a class="headerlink" href="#the-connection-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pyamp.networking.Connection">
<em class="property">class </em><tt class="descclassname">pyamp.networking.</tt><tt class="descname">Connection</tt><big>(</big><em>server</em>, <em>conn</em>, <em>addr</em>, <em>logger=None</em><big>)</big><a class="headerlink" href="#pyamp.networking.Connection" title="Permalink to this definition">¶</a></dt>
<dd><p>The Connection class handles receiving data from a single
socket connected to a server.</p>
<p>This class implements the <a class="reference internal" href="processes.html#pyamp.processes.Thread" title="pyamp.processes.Thread"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.processes.Thread</span></tt></a> and the
<a class="reference internal" href="logging.html#pyamp.logging.Loggable" title="pyamp.logging.Loggable"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.logging.Loggable</span></tt></a> interfaces.</p>
<ul class="simple">
<li>server &#8211; The server object</li>
<li>conn &#8211; The socket connection</li>
<li>addr &#8211; The address for this connection</li>
<li>logger &#8211; The LogData or Logger object for this class</li>
</ul>
<dl class="method">
<dt id="pyamp.networking.Connection.onCycle">
<tt class="descname">onCycle</tt><big>(</big><em>_i</em><big>)</big><a class="headerlink" href="#pyamp.networking.Connection.onCycle" title="Permalink to this definition">¶</a></dt>
<dd><p>Called for each cycle of the <a class="reference internal" href="processes.html#pyamp.processes.Thread" title="pyamp.processes.Thread"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.processes.Thread</span></tt></a>.</p>
<ul class="simple">
<li>i &#8211; The current cycle number</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.networking.Connection.onException">
<tt class="descname">onException</tt><big>(</big><em>_e</em>, <em>traceback</em><big>)</big><a class="headerlink" href="#pyamp.networking.Connection.onException" title="Permalink to this definition">¶</a></dt>
<dd><p>Called in the event of an exception.</p>
<ul class="simple">
<li>e &#8211; The exception</li>
<li>traceback &#8211; The traceback</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.networking.Connection.onShutdown">
<tt class="descname">onShutdown</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.networking.Connection.onShutdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Called in the event that the <a class="reference internal" href="processes.html#pyamp.processes.Thread" title="pyamp.processes.Thread"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.processes.Thread</span></tt></a> is
shutdown.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="the-server-class">
<h2>The Server class<a class="headerlink" href="#the-server-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pyamp.networking.Server">
<em class="property">class </em><tt class="descclassname">pyamp.networking.</tt><tt class="descname">Server</tt><big>(</big><em>connectionClass</em>, <em>port</em>, <em>host=''</em>, <em>logger=None</em><big>)</big><a class="headerlink" href="#pyamp.networking.Server" title="Permalink to this definition">¶</a></dt>
<dd><p>The Server class handles creating a server on a specific host and
port. It also handles multiple connections to the server while being able
to receive data from any of those connections.</p>
<p>This class implements the <a class="reference internal" href="processes.html#pyamp.processes.Thread" title="pyamp.processes.Thread"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.processes.Thread</span></tt></a> and
<a class="reference internal" href="logging.html#pyamp.logging.Loggable" title="pyamp.logging.Loggable"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.logging.Loggable</span></tt></a> interfaces.</p>
<ul class="simple">
<li>connectionClass &#8211; The class used to handle each connection</li>
<li>port &#8211; The server port number</li>
<li>host &#8211; The server host</li>
<li>logger &#8211; The LogData or Logger for this class</li>
</ul>
<dl class="method">
<dt id="pyamp.networking.Server.closeConnection">
<tt class="descname">closeConnection</tt><big>(</big><em>addr</em><big>)</big><a class="headerlink" href="#pyamp.networking.Server.closeConnection" title="Permalink to this definition">¶</a></dt>
<dd><p>Close an open connection.</p>
<ul class="simple">
<li>addr &#8211; The address for the connection to close</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.networking.Server.onCycle">
<tt class="descname">onCycle</tt><big>(</big><em>_i</em><big>)</big><a class="headerlink" href="#pyamp.networking.Server.onCycle" title="Permalink to this definition">¶</a></dt>
<dd><p>Called for every cycle of the <a class="reference internal" href="processes.html#pyamp.processes.Thread" title="pyamp.processes.Thread"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.processes.Thread</span></tt></a>.</p>
<ul class="simple">
<li>i &#8211; The current cycle number</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.networking.Server.onReceive">
<tt class="descname">onReceive</tt><big>(</big><em>addr</em>, <em>data</em><big>)</big><a class="headerlink" href="#pyamp.networking.Server.onReceive" title="Permalink to this definition">¶</a></dt>
<dd><p>Called in the event that data is received.</p>
<ul class="simple">
<li>addr &#8211; The address of the connection where the data originated</li>
<li>data &#8211; The data that was received</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.networking.Server.onShutdown">
<tt class="descname">onShutdown</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.networking.Server.onShutdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Called in the event that the <a class="reference internal" href="processes.html#pyamp.processes.Thread" title="pyamp.processes.Thread"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.processes.Thread</span></tt></a> is
shutdown.</p>
</dd></dl>

<dl class="method">
<dt id="pyamp.networking.Server.onStart">
<tt class="descname">onStart</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.networking.Server.onStart" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when the <a class="reference internal" href="processes.html#pyamp.processes.Thread" title="pyamp.processes.Thread"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.processes.Thread</span></tt></a> is started.</p>
</dd></dl>

<dl class="method">
<dt id="pyamp.networking.Server.openConnection">
<tt class="descname">openConnection</tt><big>(</big><em>conn</em>, <em>addr</em><big>)</big><a class="headerlink" href="#pyamp.networking.Server.openConnection" title="Permalink to this definition">¶</a></dt>
<dd><p>Handle the newly opened connection.</p>
<ul class="simple">
<li>conn &#8211; The socket object for the connection</li>
<li>addr &#8211; The address for the connection</li>
</ul>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">The networking module</a><ul>
<li><a class="reference internal" href="#the-connection-class">The Connection class</a></li>
<li><a class="reference internal" href="#the-server-class">The Server class</a></li>
</ul>
</li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/networking.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="index.html">pyamp v1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>